package com.cn.wanxi.service;

import com.cn.wanxi.dao.NavDao;
import com.cn.wanxi.model.NavModel;

import java.util.ArrayList;
import java.util.List;

public class NavService {
    /**
     * 这里封装数据
     *
     * @return
     */
    public List<NavModel> getNavModels() {

//        NavModel navModel = new NavModel();
//        navModel.setTitle("");
//        navModel.setHref("");
//        navModels[0] = navModel;
//        NavModel navModel1 = new NavModel();
//        navModel1.setTitle("");
//        navModel1.setHref("");
//        navModels[1] = navModel1;
        NavDao navDao = new NavDao();
        int length = navDao.getHref().length;
        List list = new ArrayList<>();
//        NavModel[] navModels = new NavModel[length];
//        "网站首页","公司介绍",一般数组在固定长度的的时候，用于查询的时候
//        如果是添加数据，用集合   集合比数组灵活

        for (int i = 0; i < length; i++) {
            NavModel navModel = new NavModel();
            navModel.setTitle(navDao.getTitle()[i]);
            navModel.setHref(navDao.getHref()[i]);
            list.add(navModel);
        }
        return list;
    }
}
